"use strict";

exports.__esModule = true;
exports.focusScrollStrategy = focusScrollStrategy;
var _utils = require("../utils");
/**
 * Scroll strategy for changed the focus position of the selection.
 *
 * @param {Core} hot Handsontable instance.
 * @returns {function(): function(CellCoords): void}
 */
function focusScrollStrategy(hot) {
  return cellCoords => {
    hot.scrollViewportTo(cellCoords.toObject(), () => {
      const activeRange = hot.getSelectedRangeActive();
      if (!activeRange) {
        return;
      }
      const {
        row,
        col
      } = activeRange.highlight;
      (0, _utils.scrollWindowToCell)(hot.getCell(row, col, true));
    });
  };
}